package org.come.MountShouHu;

import com.tool.image.ImageMixDeal;
import com.tool.tcpimg.UIUtils;
import org.come.Jpanel.MountShouhuJpanel;

import javax.swing.*;
import java.awt.*;

public class ZonglanRenderer extends JPanel implements ListCellRenderer{
    private int index;
    public static String vs;

    public ZonglanRenderer(final int index) {
        this.index = 67;
        this.index = index;
    }
    public ZonglanRenderer() {
        this.index = 67;
    }
    @Override
    public Dimension getPreferredSize() {
        return new Dimension(this.getWidth()/2 , 25);
    }
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        final ZonglanRenderer mr = new ZonglanRenderer(index);
        mr.removeAll();
        if (MountShouhuJpanel.zonglanidx == index || isSelected) {
            mr.setBackground(new Color(0,0,0,0));
        }
        else {
            mr.setOpaque(false);
        }
        mr.setLayout(new FlowLayout(0));
        final Box box = Box.createHorizontalBox();
        box.add(new JLabel() {
            {
                this.setForeground(Color.BLACK);
                this.setText("");
                try {
                    if (ImageMixDeal.userimg.getRoleShow().getFighting() != 0) {
                        {
                            {
                              /*  final Iterator<Mount> iterator = UserMessUntil.getMountlsit().listIterator();
                                while (iterator.hasNext()) {
                                    final Mount roleSummoning = iterator.next();
                                  //  final Iterator<TypeState> iterator2 = data.iterator();
                                 *//*   while (iterator2.hasNext())*//* {
                                      //  final TypeState datum = (TypeState)iterator2.next();
                                      *//*  if (datum.getType().equals(roleSummoning.getSid().toString()))*//* {
                                            this.put(roleSummoning.getMountname(), roleSummoning.getMid().intValue());
                                        }
                                    }
                                }*/
                              /*  if (mountShouhuJpanel.getZonglanmode().isEmpty()){
                                   for (int i=0;i<=mountShouhuJpanel.getZonglanmode().size()-1;i++){
                                       map.add(mountShouhuJpanel.getZonglanmode().get(i));
                                   }
                                }*/
                                if (isSelected){
                                    mr.setBackground(Color.GRAY);
                                }else mr.setBackground(Color.black);

                            }
                        };

                    }
                }
                catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });
        mr.add((Component)box);
        return (Component)mr;
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.green);
        g.setFont(UIUtils.TEXT_NAME_FONT15);
     /* for (int i=0;i<=MountShouhuJpanel.zonglan.size()-1;i++){
          g.drawString(MountShouhuJpanel.zonglan.get(i),5,15*i);
      }*/
        g.drawString(MountShouhuJpanel.zonglan.get(index), 5, 15);
     
    }
}
